package org.linlinjava.litemall.admin.task;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.service.AdminCarBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@EnableScheduling
@EnableAsync
public class AdminCarBrandDateTask {

    @Autowired
    public AdminCarBrandService brandService;

    private final Log logger = LogFactory.getLog(AdminCarBrandDateTask.class);

    @Scheduled(cron = "0 0 10 ? * MON")//每周一的上午十点钟执行一次任务
    public void getCarBrand(){
        //定时更新车型品牌
        System.out.println(LocalDateTime.now()+"  车牌型号更新定时任务开始");
        logger.info("车牌型号更新定时任务开始");
        brandService.httpRequest();
        logger.info("车牌型号更新定时任务结束");
        System.out.println(LocalDateTime.now()+"  车牌型号更新定时任务结束");
    }

//    @Scheduled(fixedDelay = 5000 ) //每五秒运行一次
//    public void printDate(){
//        System.out.println(LocalDateTime.now());
//        System.out.println("第一行"+LocalDateTime.now());
//    }

}
